<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>活动统计</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="../../../static/images/favicon.ico" th:href="@{/images/favicon.ico}">
    <link rel="stylesheet" href="../../../static/back_css/public.css" th:href="@{/back_css/public.css}" media="all" />
    <link rel="stylesheet" href="../../../static/plugin/layui/css/layui.css" th:href="@{/plugin/layui/css/layui.css}" media="all" />
    <link rel="stylesheet" href="../../../static/back_css/user_management.css" th:href="@{/back_css/user_management.css}" media="all">
</head>
<body>
    <div class="container">
        <div>
            <div style="background-color: white;height: 40px;line-height: 40px">
                <div style="width: 200px;padding-left: 15px; display: inline-block;box-sizing: border-box" th:text="'报名人数：'+${ParticipantsCount}" :></div>
                <div style="width: 200px; display: inline-block" th:text="'参与人数：'+${ParticipantsTestCount}" :></div>
                <div style="width: 200px; display: inline-block" th:text="'男生人数：'+${MaleCount}" :></div>
                <div style="width: 200px; display: inline-block" th:text="'女生人数：'+${FemaleCount}" :></div>
                <div style="width: 200px; display: inline-block" th:text="'测评次数：'+${TestCount}" :></div>
            </div>
            <div style="background-color: #f2f2f2;height: 40px;line-height: 40px">
                <div style="width: 200px; padding-left: 15px; display: inline-block;box-sizing: border-box;" th:text="'初赛完成：'+${CsTotal}" :></div>
                <div style="width: 200px; display: inline-block" th:text="'晋级复赛：'+${FsTotal}" :></div>
                <div style="width: 200px; display: inline-block" th:text="'复赛完成：'+${FsFTotal}" :></div>
                <div style="width: 200px; display: inline-block" th:text="'晋级决赛：'+${JsTotal}" :></div>
                <div style="width: 200px; display: inline-block" th:text="'决赛完成：'+${JsFTotal}" :></div>
                <!-- <div style="width: 200px; display: inline-block" th:text="'获奖人数'+${like}" :></div> -->
            </div>
        </div>
        <div class="container_top">
          <div>
            <input type="text" placeholder="请输入关键字" class="layui-input" name="id" id="demoReload" autocomplete="off">
            <button data-type="reload" class="layui-btns"><i class="layui-icon layui-icon-search search_btn"></i></button>
          </div>
          <div>
            <div id="exportAllUser" style="display: inline-block;padding:4px;background: #fff;border-radius: 4px;cursor: pointer">
              导出</div>
          </div>
        </div>
        <div class="container_content">
            <table class="layui-hide" id="test" lay-filter="test"></table>
        </div>
        <input type="hidden" id="activityId" th:value="${activityId}" />
        <input type="hidden" id="activityName" th:value="${activityName}"/>
        <input type="hidden" id="STAGE_1ST_STARTTIME" th:value="${STAGE_1ST_STARTTIME}" />
        <input type="hidden" id="STAGE_1ST_ENDTIME" th:value="${STAGE_1ST_ENDTIME}" />
        <input type="hidden" id="STAGE_2ND_STARTTIME" th:value="${STAGE_2ND_STARTTIME}" />
        <input type="hidden" id="STAGE_2ND_ENDTIME" th:value="${STAGE_2ND_ENDTIME}" />
        <input type="hidden" id="STAGE_3RD_STARTTIME" th:value="${STAGE_3RD_STARTTIME}" />
        <input type="hidden" id="STAGE_3RD_ENDTIME" th:value="${STAGE_3RD_ENDTIME}" />
    </div>

    <div class="edit_details basic_info">
      <form class="layui-form content1" action="">
        <h2>发送通知</h2>
        <div class="layui-form_content">
          <div class="layui-form-item">
            <label class="layui-form-label">阶段类型</label>
            <div class="layui-input-block">
              <input type="radio" name="STEP_TYPE" lay-filter="STEP_TYPE" value="1" title="晋级复赛">
              <input type="radio" name="STEP_TYPE" lay-filter="STEP_TYPE" value="2" title="晋级决赛">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">消息标题</label>
            <div class="layui-input-block">
              <input type="text" id="MESSAGE_TITLE" name="MESSAGE_TITLE" maxlength="60" lay-verify="title"
                autocomplete="off" placeholder="请输入消息标题（60字以内）"
                class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">消息内容</label>
            <div class="layui-input-block">
              <textarea placeholder="请输入活动简介" id="MESSAGE_CONTENT" name="MESSAGE_CONTENT" style="width: 100%;margin: 0;height: 300px;"> </textarea>
            </div>
          </div>
          <input type="hidden" id="USER_ID"/>
          <input type="hidden" id="APPRAISAL_USER_ID"/>
          <input type="hidden" id="SCHOOL_ID" />
          <input type="hidden" id="CUR_STATUS" />
          <input type="hidden" id="REG_ID" />
        </div>
        <div class="layui-form_bottom" style="text-align: center;">
          <button type="button" id="basic_cancel"
            class="layui-btn layui-btn-danger layui-btn-radius layui-bg-grays">取消</button>
          <button type="button" id="basic_confirm" lay-filter="updateBasic" lay-submit
            class="layui-btn layui-btn-radius layui-bg-oranges">确定</button>
        </div>
      </form>
    </div>
<script type="text/html" id="genderTpl">
  {{# if(d.gender === 1) { }}
    男
  {{# } else if(d.gender === 2) { }}
    女
  {{# } else { }}
    未知
  {{# } }}
</script>
<script type="text/html" id="statusTpl">
  {{# if(d.cur_STATUS === 0) { }}
    报名成功
  {{# } else if(d.cur_STATUS === 1) { }}
    初赛完成
  {{# } else if(d.cur_STATUS === 2) { }}
    晋级复赛
  {{# } else if(d.cur_STATUS === 3) { }}
    复赛完成
  {{# } else if(d.cur_STATUS === 4) { }}
    晋级决赛
  {{# } else if(d.cur_STATUS === 5) { }}
    决赛完成
  {{# } else if(d.cur_STATUS === 6) { }}
    结束
  {{# } else { }}
    未知
  {{# } }}
</script>
<script type="text/javascript" src="../../../static/plugin/layui/layui.js" th:src="@{/plugin/layui/layui.js}"></script>
<script type="text/html" id="barDemo">
    {{# if(d.cur_STATUS === 1) { }}
      {{# var currentTime = new Date(); var stage1EndTime = new Date(document.getElementById("STAGE_1ST_ENDTIME").value); if(currentTime > stage1EndTime) { }}
        <a class="layui-btn layui-btn-xs" data-method="notice" lay-event="edit">发送通知</a>
      {{#} }}
    {{# } }}
    {{# if(d.cur_STATUS === 3) { }}
      {{# var currentTime = new Date(); var stage2EndTime = new Date(document.getElementById("STAGE_2ND_ENDTIME").value); if(currentTime > stage2EndTime) { }}
        <a class="layui-btn layui-btn-xs" data-method="notice" lay-event="edit">发送通知</a>
      {{#} }}
    {{# } }}
</script>
<script>
    layui.use(['table', 'layer', 'form'], function () {
        var table = layui.table;
        var $ = layui.jquery;
        var form = layui.form;
        var exportData = "";
        var ins1;
        table_render('/getAllUserRegInfo');
        function table_render(url) {
            ins1 = table.render({
                elem: '#test',
                height: '600px',
                url: url,
                even: true,
                id: 'idTest',
                cols: [
                    [
                        { type: 'checkbox', fixed: 'left', style: 'display:none' },
                        { field: 'id', width: 70, title: '序号', hide: true },
                        { field: 'user_ID', align: 'center', width: 160, title: '微信号' },
                        { field: 'user_NAME', align: 'center', width: 100, title: '真实姓名' },
                        { field: 'gender', align: 'center', width: 80, title: '性别', sort: true, templet: '#genderTpl' },
                        { field: 'birthday', align: 'center', width: 110, title: '出生日期', sort: true },
                        { field: 'age', align: 'center', width: 110, title: '年龄', sort: true },
                        { field: 'city', align: 'center', title: '推荐地区', width: 150 },
                        { field: 'district_NAME', align: 'center', title: '推荐单位', width: 150 },
                        { field: 'telephone', align: 'center', title: '联系电话', width: 150 },
                        { field: 'sign_TIME', align: 'center', title: '报名时间', width: 150 },
                        { field: 'test_TOTAL', align: 'center', title: '测评次数', width: 120 , sort: true },
                        { field: 'test_LEVEL', align: 'center', title: '测评等级', width: 120 , sort: true },
                        { field: 'test_SCORE', align: 'center', title: '测评得分', width: 120 , sort: true },
                        { field: 'test_QUIZ_TIME', align: 'center', title: '答题用时(秒)', width: 120 , sort: true },
                        { field: 'cur_STATUS', align: 'center', title: '当前状态', width: 100, templet: '#statusTpl' },
                        { title: '操作', toolbar: '#barDemo', width: 100 }
                    ]
                ]
            });
        }
        table.on('tool(test)', function (obj) {
          var data = obj.data;
          if (obj.event === 'edit') {
            var edit_win = $(".basic_info").eq(0);
            var CUR_STATUS = data.cur_STATUS;
            var activityName = $("#activityName").val();
            var STAGE_2ND_STARTTIME = $("#STAGE_2ND_STARTTIME").val();
            var STAGE_2ND_ENDTIME = $("#STAGE_2ND_ENDTIME").val();
            var STAGE_3RD_STARTTIME = $("#STAGE_3RD_STARTTIME").val();
            var STAGE_3RD_ENDTIME = $("#STAGE_3RD_ENDTIME").val();
            console.log(STAGE_2ND_STARTTIME);
            if (CUR_STATUS == 1) {
              $('input[name="STEP_TYPE"][value="1"]').prop("checked", true);
              $('input[name="STEP_TYPE"][value="1"]').prop("disabled", false);
              $('input[name="STEP_TYPE"][value="2"]').prop("disabled", true);
              edit_win.find("#MESSAGE_TITLE").val("晋级复赛通知");
              var content = "恭喜您，您参与的活动["+ activityName+"]已晋级到复赛，请您于"+STAGE_2ND_STARTTIME+"至"+STAGE_2ND_ENDTIME+"到指定地点参加复赛，会有参赛会务组与您联系，请注意接听电话";
              edit_win.find("#MESSAGE_CONTENT").val(content);
            } else {
              $('input[name="STEP_TYPE"][value="2"]').prop("checked", true);
              $('input[name="STEP_TYPE"][value="2"]').prop("disabled", false);
              $('input[name="STEP_TYPE"][value="1"]').prop("disabled", true);
              edit_win.find("#MESSAGE_TITLE").val("晋级决赛通知");
              var content = "恭喜您，您参与的活动["+ activityName+"]已晋级到决赛，请您于"+STAGE_3RD_STARTTIME+"至"+STAGE_3RD_ENDTIME+"到指定地点参加决赛，会有参赛会务组与您联系，请注意接听电话";
              edit_win.find("#MESSAGE_CONTENT").val(content);
            }
            layui.form.render('radio');
            edit_win.find("#USER_ID").val(data.user_ID);
            edit_win.find("#APPRAISAL_USER_ID").val(data.appraisal_USER_ID);
            edit_win.find("#SCHOOL_ID").val(data.company);
            edit_win.find("#CUR_STATUS").val(data.cur_STATUS);
            edit_win.find("#REG_ID").val(data.id);
            
            $(".basic_info").css("display", "block")
          }
        });
        $("#basic_cancel").click(function () {
          $(".basic_info").css("display", "none")
        });
        form.on("submit(updateBasic)", function (data) {
          var obj = {};
          obj["ACTIVITY_ID"] = $("#activityId").val();
          obj["STEP_TYPE"] = $('input[name="STEP_TYPE"]:checked').val();
          obj['CUR_STATUS'] = $("#CUR_STATUS").val();
          obj["MESSAGE_TITLE"] = $("#MESSAGE_TITLE").val();
          obj["MESSAGE_CONTENT"] = $("#MESSAGE_CONTENT").val();
          obj["USER_ID"] = $("#USER_ID").val();
          obj["APPRAISAL_USER_ID"] = $("#APPRAISAL_USER_ID").val();
          obj["SCHOOL_ID"] = $("#SCHOOL_ID").val();
          obj["REG_ID"] = $("#REG_ID").val();

          layer.load(1);
          $.ajax({
            url: '/addMessage',
            type: 'POST',
            data: JSON.stringify(obj),
            contentType: "application/json",
            success: function (result) {
                window.location.href = '/accountWorkDetails';
            },
            error: function (reason) {
              layer.msg("网络错误");
            }
          })
          return false;
        })

        $(".search_btn").on("click", function () {
          table.reload("idTest", {
            where: {
              USER_NAME: $("#demoReload").val()//搜索的关键字
            }
          })
          return false;
        });
        $("#exportAllUser").click(function () {
          layer.msg("正在导出数据，请勿重复操作，请稍候···");
          window.location.href = '/exportAllWorkDetail';
        })
    });
</script>
</body>
</html>